<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>The source code</title>
  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  <style type="text/css">
    .highlight { display: block; background-color: #ddd; }
  </style>
  <script type="text/javascript">
    function highlight() {
      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
    }
  </script>
</head>
<body onload="prettyPrint(); highlight();">
  <pre class="prettyprint lang-js">/*
 * Copyright (c) 2016 JUI All rights reserved.
 */

;(function () {

<span id='JUI-Msg'>    /**
</span>     * 消息提醒框&lt;br&gt;
     * &lt;pre&gt;
     function alert1() {
	JUI.Msg.alert('我的消息','这是一个提示信息！',function(){
	    alert('OK')
	});
}

     function confirm1() {
	JUI.Msg.confirm('确认对话框', '您想要退出该系统吗？', function(r){
		if (r){
			alert('退出')
		}else{
			alert('不退出')
		}
	});
}

     function prompt1() {
	JUI.Msg.prompt('提示信息', '请输入你的姓名：', function(r,msg){
		if(r) {
			alert('你的姓名是：' + msg);
		}
	});

}
     * &lt;/pre&gt;
     * @class JUI.Msg
     * @extends JUI.Dialog
     */
    var Msg = JUI.Class('Msg', {
<span id='global-method-constructor'>        /**
</span>         * @constructor
         * @ignore
         */
        init: function (opts) {
            this._super(opts);
        }
    	,setContent:function(html) {
    		this.getContentDiv().html(html);
    	}
    	,getContentDiv:function() {
    		return $('#' + this.opt('contentId'));
    	}
    }, JUI.Dialog);

<span id='global-method-getMsg'>    /**
</span>     * @ignore
     */
    var getMsg = function (callback) {
    	var contentId = 'jui-msg-id-' + JUI.getId();
        $('body').append($('&lt;div id=&quot;' + contentId + '&quot; style=&quot;min-width:200px;&quot;&gt;&lt;/div&gt;'));

        var msg = new Msg({
            contentId: contentId
            , onOk: function () {
                callback &amp;&amp; callback.call(this,true);
                this.hide();
            }
            , onCancel: function () {
                callback &amp;&amp; callback.call(this,false);
                this.hide();
            }
            , zindex: 1000
        });

        msg.setNextDo(function () {
            this.hideBtn(1);// 隐藏取消按钮
        });
        
        return msg;
    }

<span id='JUI-Msg-static-property-'>    /**
</span>     * 确认框
     * @static
     */
    Msg.confirm = function (title, content, fn) {
        callback = fn;
        var msg = getMsg(fn);
        msg.setTitle(title);
        msg.setContent(content);
        msg.show();
        msg.setNextDo(function () {
            this.showBtn(1);
        });
        return msg;
    }

<span id='JUI-Msg-static-property-'>    /**
</span>     * 提醒框
     * @static
     */
    Msg.alert = function (title, content, fn) {
        var msg = Msg.confirm(title, content, fn);
        msg.setNextDo(function () {
            this.hideBtn(1);// 隐藏取消按钮
        });
    }

<span id='JUI-Msg-static-property-'>    /**
</span>     * 文版本提示框
     * @static
     */
    Msg.prompt = function (title, content, fn) {
    	var promptInputId = 'jui-msg-promptinput-id' + JUI.getId();
        var content = '&lt;div&gt;' + content + '&lt;/div&gt;&lt;div&gt;&lt;input id=&quot;'+promptInputId+'&quot; type=&quot;text&quot; style=&quot;width:250px;&quot;/&gt;&lt;/div&gt;';
        var msg = Msg.confirm(title, content, function (r) {
            var val = $('#' + promptInputId).val();
            fn(r, val);
        });
        msg.getContentDiv().width('auto');
    }

})();</pre>
</body>
</html>
